public class ThreadDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            System.out.println("0号线程");
        });
        Thread thread1 = new Thread(()->{
            try {
                thread.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("1号线程");
        });
        Thread thread2 = new Thread(()->{
            try {
                thread1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("2号线程");
        });
        Thread thread3 = new Thread(()->{
            try {
                thread2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("3号线程");
        });
        Thread thread4 = new Thread(()->{
            try {
                thread3.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("4号线程");
        });
        Thread thread5 = new Thread(()->{
            try {
                thread4.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("5号线程");
        });
        Thread thread6 = new Thread(()->{
            try {
                thread5.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("6号线程");
        });
        Thread thread7 = new Thread(()->{
            try {
                thread6.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("7号线程");
        });
        Thread thread8 = new Thread(()->{
            try {
                thread7.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("8号线程");
        });
        Thread thread9 = new Thread(()->{
            try {
                thread8.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("9号线程");
        });
        Thread thread10 = new Thread(()->{
            try {
                thread9.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("10号线程");
        });
        Thread thread11 = new Thread(()->{
            try {
                thread10.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("11号线程");
        });
        Thread thread12 = new Thread(()->{
            try {
                thread11.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("12号线程");
        });
        Thread thread13 = new Thread(()->{
            try {
                thread12.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("13号线程");
        });
        Thread thread14 = new Thread(()->{
            try {
                thread13.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("14号线程");
        });
        Thread thread15 = new Thread(()->{
            try {
                thread14.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("15号线程");
        });
        Thread thread16 = new Thread(()->{
            try {
                thread15.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("16号线程");
        });
        Thread thread17 = new Thread(()->{
            try {
                thread16.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("17号线程");
        });
        Thread thread18 = new Thread(()->{
            try {
                thread17.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("18号线程");
        });
        Thread thread19 = new Thread(()->{
            try {
                thread18.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("19号线程");
        });
        thread.start();
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
        thread6.start();
        thread7.start();
        thread8.start();
        thread9.start();
        thread10.start();
        thread11.start();
        thread12.start();
        thread13.start();
        thread14.start();
        thread15.start();
        thread16.start();
        thread17.start();
        thread18.start();
        thread19.start();
        thread19.join();
        System.out.println("ok");
    }
}
